/****
 * 帐套管理
 * by hmm 2014-08-12
 */

define(['./module'], function (services) {
    "use strict";
    services.factory('accountsFactory', ['$http','urlBase', function ($http,urlBase) {

//            var urlBase = 'http://10.188.192.200:8080/stockAccount';
            var accountsFactory = {};
            var url = 'account/';
            /**
             获取用户所有帐套
             **/
            accountsFactory.getUserStockAccounts = function () {
                return $http.get(urlBase +url + 'stocks/user');
            };

            /***
             根据帐套id获取帐套信息
             **/
            accountsFactory.getStockAccount = function (accountId) {
                return $http.get(urlBase + accountId);
            };

            /***
             新增帐套
             **/
            accountsFactory.insertStockAccount = function (stockAccount) {
                return $http.post(urlBase,stockAccount);
            };

            /***
             更新帐套
             **/
            accountsFactory.updateStockAccount = function (stockAccount) {
                return $http.put(urlBase + stockAccount.accountId,stockAccount);
            };

            /**
             删除帐套，级联删除帐套下所有数据
             **/
            accountsFactory.deleteStockAccount = function (accountId) {
                return $http.delete(urlBase + accountId);
            };

            return accountsFactory;
        }]);
    })